home *** CD-ROM | disk | FTP | other *** search
- Path: lince.lander.es!news
- From: Marcos Mayorga Aguirre <sparda@lander.es>
- Newsgroups: comp.lang.c++
- Subject: Re: Need help with an array of pointers
- Date: Tue, 26 Mar 1996 20:32:32 +0100
- Organization: Lander
- Message-ID: <31584650.F18@lander.es>
- References: <3157FBAF.32A3@village.ios.com>
- NNTP-Posting-Host: ppp055.lander.es
- Mime-Version: 1.0
- Content-Type: text/plain; charset=iso-8859-2
- Content-Transfer-Encoding: 7bit
- X-Mailer: Mozilla 2.0GoldB1 (Win95; I)
-
- Keith Boruff wrote:
- >
- > Suppose I have an array of pointers:
- >
- > char *WordPtr[] = {"Jack", "Joe", "Bob"};
- >
- > How do I print the address value of each pointer element (i.e., the
- > address that each pointer points to)? The only addresses I seem to be
- > able to print are the addresses of the array elements themselves.
- >
- > I would appreciate any help on this subject. An array of pointers is a
- > confusing topic to me and I could use all the help I can get.
- >
- > Keith Boruff
- > Long Island, NY
-
- ok, at this time you have in memory
-
- WordPtr[0] --> "Jack"
- WordPtr[1] --> "Joe"
- WordPtr[2] --> "Bob"
-
- if you want view the adresses of "Jack", "joe" and "Bob":
-
- printf("Adress of Jack: %P\n",WordPtr[0]);
- printf("Adress of Joe: %P\n",WordPtr[1]);
- printf("Adress of Bob: %P\n",WordPtr[2]);
-
- if you want to print the names of "Jack", "joe" and "Bob":
-
-
- printf("%s\n",WordPtr[0]);
- printf("%s\n",WordPtr[1]);
- printf("%s\n",WordPtr[2]);
-
- you can also get the "o" character of "Joe" with WordPtr[1][1] or
- with *(WordPtr[1]+1)
-
-
- I don't speak english very good, sorry
-
- --
-
-
- ***********************************************************
- *** Marcos Mayorga <sparda@lander.es> ***
- *** Busco chica guapa, inteligente, 386 o superior ***
- ***********************************************************
-